#include "cone_detect_ros.h"

// TODO: see http://www.ros.org/wiki/recognition_pipeline/Tutorials/Adding%20a%20new%20object%20detector%20in%20the%20recognition%20infrastructure

namespace rein
{

void ConeDetector::detect()
{
  // Using the image_, point_cloud_ and masks_ fields as input data
  // and implement the 'cone' object detection algorithm here

  IplImage* imgIn;

  try {
    // TODO: where to get bridge_?
    imgIn = bridge_.imgMsgToCv(image_);
  }
  catch (sensor_msgs::CvBridgeException error) {
    ROS_ERROR("error");
  }

  Detection cone_detection;
  cone_detection.label = "cone";
  cone_detection.mask.roi.x = 10;
  cone_detection.mask.roi.y = 10;
  cone_detection.mask.roi.width = 20;
  cone_detection.mask.roi.height = 30;
  cone_detection.score = 0.5;
  cone_detection.detector = getName();

  detections_.detections.push_back(cone_detection);

}


void ConeDetector::loadModels(const std::vector<std::string>& models)
{
  // TODO
  for (size_t i=0;i<models.size();++i) {
    std::string model_blob;
    model_storage_->loadModel(models[i],getName(),model_blob);

    // the model is now stored in model_blob in some serialized form
    // it's the detector's job to serialize/deserialize the model
  }
}

}

